import 'package:flutter/material.dart';

class Widget_AspectRatio_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_AspectRatio_State();
  }
}

class Widget_AspectRatio_State extends State<Widget_AspectRatio_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(title: Text("AspectRatio"),),
          body: Container(
            width: 100.0,
            child: AspectRatio(
              aspectRatio: 2.0 / 3.0,
              child: Container(
                color: Color(0xffff0000),
              ),
            ),
          )
      ),
    );
  }
}

/**
 * 强制子部件的宽度和高度具有给定的宽高比,可以父容器给定一个宽或者高，来换算另一个值
    const AspectRatio({
    Key key,
    @required this.aspectRatio,//宽高比,不能为null，必须大于0
    Widget child
    })
 * */